package com.cskaoyan.controller;

import com.cskaoyan.module.bean.BaseRespVo;
import com.cskaoyan.module.bean.vo.MallAftersaleVO;
import com.cskaoyan.module.bo.AfterSaleId;
import com.cskaoyan.module.pojo.MarketAftersale;
import com.cskaoyan.service.MallAfterSaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author :ligenghuisheng
 * @Description:
 * @Date :2022/4/6  21:32
 */
@RestController
@RequestMapping("admin/aftersale")
public class MallAfterSaleController {

    @Autowired
    MallAfterSaleService afterSaleService;

    //展示售后管理的首页
    @RequestMapping("list")
    public BaseRespVo list(Integer page , Integer limit, String status , String sort,String order, String aftersaleSn,Integer orderId) {

        MallAftersaleVO aftersaleVO  = afterSaleService.listOrder( page ,  limit,  status ,  sort, order,aftersaleSn,orderId);



        return BaseRespVo.ok(aftersaleVO);
    }

    //单一通过
    @PostMapping("recept")

    public BaseRespVo batchRecept(@RequestBody MarketAftersale marketAftersale){
        afterSaleService.batchRecept(marketAftersale);



        return BaseRespVo.ok("成功");
    }
    //批量通过
    @PostMapping("batch-recept")
    public BaseRespVo batchReceptMany(@RequestBody AfterSaleId id){
        afterSaleService.batchReceptMany(id);

        return BaseRespVo.ok("成功");
    }


    //单一不通过
    @PostMapping("reject")
    public BaseRespVo batchRejectSingle(@RequestBody MarketAftersale marketAftersale){

        afterSaleService.batchRejectSingle(marketAftersale);

        return BaseRespVo.ok("成功");
    }

    //批量不通过
    @PostMapping("batch-reject")

    public BaseRespVo batchReject(@RequestBody AfterSaleId ids){

        afterSaleService.batchRehect(ids);
        return BaseRespVo.ok("成功");
    }

    //订单退款
    @PostMapping("refund")
    public BaseRespVo refundMoney(@RequestBody MarketAftersale marketAftersale){

        afterSaleService.refund(marketAftersale);
        return BaseRespVo.ok("退款成功");
    }



}
